package com.qingcheng.controller.scheduled;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.service.order.CategoryReportService;
import com.qingcheng.service.order.OrderService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;


import java.time.LocalDate;
import java.util.Date;

@Controller
public class OrderScheduled {
    @Reference
    private OrderService orderService;

    @Reference
    private CategoryReportService categoryReportService;

   // @Scheduled(cron = "0/10 * * * * ?")
    public void orderTimeOutHandle(){
        System.out.println("每隔10秒检查一次"+new Date());
        orderService.closeOrder();
    }


 //   @Scheduled(cron = "0 0 2 * * ?")
    public void insertCategoryReport(){
        System.out.println("每天凌晨2点更新订单统计信息");
        LocalDate localDate=LocalDate.now().minusDays(1);
        categoryReportService.insertCategoryReport(localDate);
    }
}
